from subprocess import check_call, CalledProcessError
from os.path import isfile, splitext

def convert(pdf):
    '''Convert a PDF to JPG'''
    if not isfile(pdf):
        showerror("ERROR", "Can't find {0}".format(pdf))
        return

    jpg = splitext(pdf)[0] + ".jpg"

    try:
        check_call(["convert", "-quality", "100%", pdf, jpg])
        print "Converted", "{0} converted".format(pdf)
    except (OSError, CalledProcessError) as e:
        print "ERROR", "ERROR: {0}".format(e)

convert('/home/shibli/Desktop/02-intro-python.pdf')
